/**
 * @Author: Jackey 327156719@qq.com
 * @Date: 2024-12-03 13:34:02
 * @LastEditors: Jackey 327156719@qq.com
 * @LastEditTime: 2024-12-03 13:34:21
 * @FilePath: src/main/java/org/springblade/modules/admin/utils/AsyncConfiguration.java
 * @Description: 这是默认设置,可以在设置》工具》File Description中进行配置
 */
package org.springblade.modules.admin.utils;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

// 配置类
@Configuration
@EnableAsync  // 开启异步支持
public class AsyncConfiguration {

    @Bean
    public AsyncTaskExecutor asyncTaskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.setMaxPoolSize(10);
        executor.setQueueCapacity(25);
        executor.setThreadNamePrefix("AsyncTask-");
        executor.initialize();
        return executor;
    }
}
